home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 49
/
Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso
/
-serious-
/
misc
/
football
/
user
/
html_table.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-11-29
|
19KB
|
572 lines
/* Mode=Run */
/* ***********************************************************************
HTMLtable.rexx v1.0 (27-5-99) for THE FOOTBALL REXX SUITE
-----------------------------------------------------------
by Kevin Lambert (amiga4000@bizonline.co.uk)
-This script will generate an HTML file of the normal league table.
-To use HTMLtable.rexx you can run it by using the 'Run Script' button
on the Football main panel. Select HTMLtable.rexx from the file
requester and away you go. A file (????tab.html) will be written to RAM:
but this location can be changed. View the file with any browser that
supports tables.
-Look through the script if you want to change some Options :-)
Version Date History
--------------------------------------------------------------------------
1.0 270599 First release.
170699 Fixed inherited bug from League where if all teams
had zero points, the promotion bar was still
displayed.
1.1 080799 Reprogrammed for usage with HTML-Templates
speed it up
two outputs (calling from Football or another script -flag-)
250899 Update by Mark. Added error msg to file checks.
Now opens file (to write to) when run from Football
and added messages in the same scenario.
110999 Converted to use locale. Some error messages, before
reading the locale, will still be in English.
************************************************************************** */
PARSE ARG league_file DateStart DateEnd flag
version = 1
htmlpath = "HTML/" /* path for your HTML files */
lname = league_file /* name for the HTML file taken from league file name */
output_file = "Data/League.output"
input_file = '.stats'
input2_file = '.sf'
input3_file = '.df'
title = '*LEAGUE_NAME='
points_win = '*POINTS_PER_WIN='
points_drw = '*POINTS_PER_DRW='
points_lse = '*POINTS_PER_LSE='
points_gls = '*POINTS_PER_GLS='
releg = '*RELEGATION='
playother = '*PLAY_OTHER='
promoted = '*PROMOTED='
team_counter = '*COUNTR='
team = '*TEAM='
played = '*PLY='
won = '*WIN='
drawn = '*DRW='
lost = '*LST='
goalsf = '*GOF='
goalsa = '*GOA='
points = '*PTS='
separator = '*'
teams. = '???'
teams2. = '???'
m_ply. = '???'
m_win. = '???'
m_drw. = '???'
m_lost. = '???'
m_gof. = '???'
m_goa. = '???'
m_pts. = '???'
teams_ctr = 0
playo = 2
reg = 2
ptsgls = 0
ptswin = 2
ptsdrw = 1
ptslse = 0
promo = 0
not_played = '__ __'
if pos("/",league_file) > 0 then
parse var league_file . "/" lname
lname = strip(lname)
league_file = "Data/"league_file
if open(datafile,"Data/Football.locale",'r') then do
line = readln(datafile)
locdir = strip(line)
close(datafile)
end
else do
say
say "ERROR : (HTML_Table)"
say
say "Cannot read 'Data/Football.locale' for the locale settings."
exit
end
locdir = locdir"User/HTML_Table.data"
if open(datafile,"ENV:FootballRXPath",'r') then do
line = readln(datafile)
rxdir = strip(line)
close(datafile)
end
else
rxdir = "SYS:Rexxc/"
if exists(locdir) > 0 then do
address command rxdir'rx 'locdir
VarCount = getclip('VarCount')
do i = 1 to VarCount
interpret getclip('var.'i)
end
end
else do
say
say "ERROR : (HTML_Table)"
say
say "Cannot find '"locdir"' to read locale settings."
exit
end
if exists(league_file || input_file) = 0 then do
say
say htmt_error
say
say htmt_t1"'"league_file || input_file"'."
exit
end
if exists(league_file || input2_file) = 0 then do
say
say htmt_error
say
say htmt_t1"'"league_file || input2_file"'."
exit
end
if exists(league_file || input3_file) = 0 then do
say
say htmt_error
say
say htmt_t1"'"league_file || input3_file"'."
exit
end
tcount = 0
/* df */
if open(datafile,league_file || input3_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
/*
LEAGUE_NAME=
points_win = '*POINTS_PER_WIN='
points_drw = '*POINTS_PER_DRW='
points_lse = '*POINTS_PER_LSE='
points_gls = '*POINTS_PER_GLS='
releg = '*RELEGATION='
playother = '*PLAY_OTHER='
promoted = '*PROMOTED='
*/
if pos(title,line) > 0 then league_title = delstr(line,1,13)
if pos(points_win,line) > 0 then ptswin=delstr(line,1,16)
if pos(points_drw,line) > 0 then ptsdrw=delstr(line,1,16)
if pos(points_lse,line) > 0 then ptslse=delstr(line,1,16)
if pos(points_gls,line) > 0 then ptsgls=delstr(line,1,16)
if pos(releg,line) > 0 then reg = delstr(line,1,12)
if pos(playother,line) > 0 then playo = delstr(line,1,12)
if pos(promoted,line) > 0 then promo = delstr(line,1,10)
/* Read Names Of The Teams */
if pos(separator,line) = 0 then do
line = strip(line)
tcount = tcount + 1
teams.tcount = line
end
end
close(datafile)
end
else do
say
say htmt_error
say
say htmt_t2"'"league_file || input3_file"'"htmt_t4
exit
end
/* stats = StartDaten, im Normalfall=0 */
if open(datafile,league_file || input_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
/*
team = '*TEAM='
played = '*PLY='
won = '*WIN='
drawn = '*DRW='
lost = '*LST='
goalsf = '*GOF='
goalsa = '*GOA='
points = '*PTS='
*/
if pos(team,line) > 0 then
teams_ctr = teams_ctr + 1
if pos(played,line) > 0 then m_ply.teams_ctr = delstr(line,1,5)
if pos(won,line) > 0 then m_won.teams_ctr = delstr(line,1,5)
if pos(drawn,line) > 0 then m_drw.teams_ctr = delstr(line,1,5)
if pos(lost,line) > 0 then m_lost.teams_ctr = delstr(line,1,5)
if pos(goalsf,line) > 0 then m_gof.teams_ctr = delstr(line,1,5)
if pos(goalsa,line) > 0 then m_goa.teams_ctr = delstr(line,1,5)
if pos(points,line) > 0 then m_pts.teams_ctr = delstr(line,1,5)
end
close(datafile)
end
else do
say
say htmt_error
say
say htmt_t2"'"league_file || input_file"'"htmt_t4
exit
end
/* sf = Resultate der Spiele */
LineNo=0
DasDatumNoch=0
if open(datafile,league_file || input2_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
/* */
If DateStart~='' then do
LineNo=LineNo+1
if (pos('*DATE: ',upper(line))=1 & (DasDatumNoch=1)) then
leave
if ((pos('*DATE: ',upper(line))=1) & (LineNo>=DateStart) & (LineNo<=DateEnd)) then do
If LineNo>=DateEnd then DasDatumNoch=1
End
End
/* */
if pos(separator,line) = 0 then do
if pos(not_played,line) = 0 then do
home_team = strip(substr(line,1,30))
goals_for = substr(line,32,2)
goals_aga = substr(line,37,2)
away_team = strip(substr(line,41,30))
do i=1 to teams_ctr
if home_team = teams.i then do
m_ply.i = m_ply.i + 1
m_gof.i = m_gof.i + goals_for
m_goa.i = m_goa.i + goals_aga
Select
When goals_for < goals_aga then do
m_lost.i= m_lost.i + 1
m_pts.i = m_pts.i + ptslse
end
When goals_for > goals_aga then do
m_won.i = m_won.i + 1
m_pts.i = m_pts.i + ptswin
end
Otherwise do
m_drw.i = m_drw.i + 1
m_pts.i = m_pts.i + ptsdrw
end
end /* Select */
m_pts.i = m_pts.i + (goals_for * ptsgls)
end /* If home */
if away_team = teams.i then do
m_ply.i = m_ply.i + 1
m_gof.i = m_gof.i + goals_aga
m_goa.i = m_goa.i + goals_for
Select
When goals_for < goals_aga then do
m_won.i = m_won.i + 1
m_pts.i = m_pts.i + ptswin
end
When goals_for > goals_aga then do
m_lost.i= m_lost.i + 1
m_pts.i = m_pts.i + ptslse
end
Otherwise do
m_drw.i = m_drw.i + 1
m_pts.i = m_pts.i + ptsdrw
end
end /* Select */
m_pts.i = m_pts.i + (goals_aga * ptsgls)
end /* If away */
end /* do */
end /* If not --- --- */
end
end
close(datafile)
end
else do
say
say htmt_error
say
say htmt_t2"'"league_file || input2_file"'"htmt_t4
exit
end
/* Daten ungeordnet in Data/League.output werfen */
if open(outfile,output_file,"w") then do
do i=1 to teams_ctr
line = teams.i
line = insert(" ",line,length(line)+1,30-length(line))
mp = right(m_ply.i,3) /* TABGAMES */
mw = right(m_won.i,3) /* TABWON */
md = right(m_drw.i,3) /* TABDRAWS */
ml = right(m_lost.i,3) /* TABLOST */
mgf = right(m_gof.i,5) /* TABOWNGOALS */
mga = right(m_goa.i,5) /* TABOTHGOALS */
mpts = right(m_pts.i,7) /* TABPOINTS */
writech(outfile,line" "mp" "mw" "md" "ml" "mgf" "mga" "mpts" ")
itemp=mgf-mga /* TABGOALDIFF */
if itemp>0 then
itemp=insert("+",itemp,0,1)
itemp=right(itemp,4)
writeln(outfile,itemp)
end
close(outfile)
end
else do
say
say htmt_error
say
say htmt_t3"'"output_file"'."
exit
end
address command 'Exec/footsort '
/* Daten geordnet aus Data/League.output auslesen */
if open(datafile2,output_file,'r') then do
do i=1 to tcount
line = readln(datafile2)
teams.i = line
teams2.i = line
end
close(datafile2)
end
else do
say
say htmt_error
say
say htmt_t2"'"output_file"'"htmt_t4
exit
end
/*
mp mw md ml mgf mga mpts tempdiff
Arsenal 38 22 12 4 59 17 78 +42
*/
ctr = 0
do while swapctr > 0
swapctr=9
do i=1 to tcount-1
swapdone=0
j = i + 1
/* sortieren nach TorDiff, wenn die Punkte gleich sind */
if strip(substr(teams.i,64,7)) = strip(substr(teams.j,64,7)) then do
goaldiffa = strip(substr(teams.i,77,5))
goaldiffb = strip(substr(teams.j,77,5))
if goaldiffa < goaldiffb then do
teams.i = teams2.j
teams.j = teams2.i
teams2.i= teams.i
teams2.j= teams.j
swapdone= 1
ctr = ctr + 1
end
end
if swapdone = 1 then
break
end
if ctr = 0 then
swapctr = 0
else
ctr = 0
end
posreg = 0
pospro = 0
/* this bit of code checks to see which teams are relegated */
if reg > 0 then do
wherereg = tcount - reg
regpts = strip(substr(teams.wherereg,64,7))
do i=tcount to 1 by -1
b = (((tcount-1) * playo) - strip(substr(teams.i,35,3))) * ptswin
c = strip(substr(teams.i,64,7)) + b
/* calculates the max points avail */
if c < regpts then posreg = i
if c = regpts & strip(substr(teams.i,35,3)) = ((tcount-1) * playo) then
posreg = i
end
if posreg < (wherereg+1) & posreg ~= 0 then /* was 0 - set to reqd pos if higher */
posreg = wherereg + 1
/* Bug fix 0305 - relegation bar problems */
end
/* ---------------------------------------------- */
if promo > 0 then do /* this bit of code checks to see which teams are promoted */
wherepro = promo + 1
propts = strip(substr(teams.wherepro,64,7)) /* was 64,4 */
do i=1 to tcount
if strip(substr(teams.i,35,3)) > 0 then
b = (((tcount-1) * playo) - strip(substr(teams.i,35,3))) * ptswin
else
b = 0
c = strip(substr(teams.i,64,7)) + b
if c > propts then pospro = i /* calculates the max points avail */
end
if pospro > (wherepro-1) & pospro ~= 0 then
pospro = wherepro - 1 /* was 0 - set to reqd pos if lower */
end
If flag=1 then do /* called from another rexx.script */
do i=1 to tcount
var.i = "teams."i" = " d2c(34)||teams.i||d2c(34)
end
setclip('VarCount', tcount)
do i = 1 to tcount
call setclip('var.'i, var.i)
end
exit
end
else do
if open(stats,htmlpath||lname||"tab.html","w") = 0 then do
say
say htmt_error
say
say htmt_t2"'"htmlpath||lname||"tab.html'"htmt_t5
exit
end
end
/* -------------------------------HTML options--------------------------------------- */
cs = 2 /* Cellspacing */
cp = 2 /* Cellpadding */
br = 1 /* Border size */
pb = #779977 /* Page Background colour */
bg = #55ee55 /* top team colours */
fc = #000000 /* Default table font colour*/
pc = #eeeeee /* Points Highlight colour */
tw = "80%" /* Table width */
/* sum of tdw percents has to be 100% */
tdw_pos = "5%"
tdw_team = "50%"
tdw_pld = "5%"
tdw_won = "5%"
tdw_drw = "5%"
tdw_los = "5%"
tdw_gf = "5%"
tdw_ga = "5%"
tdw_poi = "5%"
tdw_gdiff = "5%"
call writeln(stats,"<HTML>")
call writeln(stats,"")
call writeln(stats,"<!-- Created with HTMLtable.rexx (v1.1) Script for Football -->")
call writeln(stats,"<!-- A football tracking program for the Amiga -->")
call writeln(stats,"")
call writeln(stats,"<HEAD>")
call writeln(stats,"<TITLE>")
call writeln(stats,lname" League Table")
call writeln(stats,"</TITLE>")
call writeln(stats,"")
call writeln(stats,"<META NAME=""author"" CONTENT=""Kevin Lambert (amiga4000@bizonline.co.uk)"">")
call writeln(stats,"<META NAME=""generator"" CONTENT=""HTML_Table.rexx"">")
call writeln(stats,"")
call writeln(stats,"</HEAD>")
call writeln(stats,"")
call writeln(stats,"<BODY BGCOLOR="""pb""">")
call writeln(stats,"<DIV ALIGN=""center"">")
call writeln(stats,"<TABLE CELLSPACING="""cs""" CELLPADDING="""cp""" BORDER="""br"""BGCOLOR=""#ccddcc"" WIDTH="""tw""">")
call writeln(stats,"<TR><TH COLSPAN=""10"" BGCOLOR=""#aaaaee"">"center(league_title,88)"</TH></TR>")
call writeln(stats,"<TR ALIGN=""center"" VALIGN=""top"" BGCOLOR=""#aaaaee""><TD width="""tdw_pos""" valign=""top"">"htmt_t6"</TD><TD width="""tdw_team""" valign=""top"">"htmt_t7"</TD><TD width="""tdw_pld""" valign=""top"">"htmt_t8"</TD><TD width="""tdw_won""" valign=""top"">"htmt_t9"</TD><TD width="""tdw_drw""" valign=""top"">"htmt_t10"</TD><TD width="""tdw_los""" valign=""top"">"htmt_t11"</TD><TD width="""tdw_gf""" valign=""top"">"htmt_t12"</TD><TD width="""tdw_ga""" valign=""top"">"htmt_t13"</TD><TD width="""tdw_poi""" valign=""top"">"htmt_t14"</TD><TD width="""tdw_gdiff""" valign=""top"">"htmt_t15"</TD></TR>")
call writeln(stats,"<TR><TD HEIGHT=""1"" BGCOLOR=""#000000"" COLSPAN=""10""></TD></TR>")
do i=1 to tcount
if i > 1 then bg = "#ccddcc" /* table Background colour */
if strip(substr(teams.i,76,5)) = 0 then teams.i=overlay("",teams.i,76,5," ")
if i >= posreg & posreg~=0 then teams.i = upper(teams.i)
if i >= posreg & posreg~=0 then bg = "#ff5555" /* possible relegation background colour */
if i >= posreg & posreg~=0 then fc = "#ffffff" /* possible relegation font colour*/
if i<10 then do
if i = 1 then teams.i = upper(teams.i)
end
teams.i=insert("</FONT></TD></TR>",teams.i,84)
teams.i=insert("</FONT></TD><TD BGCOLOR="""BG""" ALIGN=""CENTER"" VALIGN=""MIDDLE""><FONT COLOR="""fc""">",teams.i,71)
teams.i=insert("</FONT></TD><TD BGCOLOR="""PC""" ALIGN=""CENTER"" VALIGN=""MIDDLE""><FONT COLOR=""#000000"">",teams.i,62)
teams.i=insert("</FONT></TD><TD BGCOLOR="""BG""" ALIGN=""CENTER"" VALIGN=""MIDDLE""><FONT COLOR="""fc""">",teams.i,56)
teams.i=insert("</FONT></TD><TD BGCOLOR="""BG""" ALIGN=""CENTER"" VALIGN=""MIDDLE""><FONT COLOR="""fc""">",teams.i,50)
teams.i=insert("</FONT></TD><TD BGCOLOR="""BG""" ALIGN=""CENTER"" VALIGN=""MIDDLE""><FONT COLOR="""fc""">",teams.i,46)
teams.i=insert("</FONT></TD><TD BGCOLOR="""BG""" ALIGN=""CENTER"" VALIGN=""MIDDLE""><FONT COLOR="""fc""">",teams.i,42)
teams.i=insert("</FONT></TD><TD BGCOLOR="""BG""" ALIGN=""CENTER"" VALIGN=""MIDDLE""><FONT COLOR="""fc""">",teams.i,38)
teams.i=insert("</FONT></TD><TD BGCOLOR="""BG""" ALIGN=""CENTER"" VALIGN=""MIDDLE""><FONT COLOR="""fc""">",teams.i,35)
teams.i=insert("</FONT></TD><TD BGCOLOR="""BG""" ALIGN=""LEFT"" VALIGN=""MIDDLE""><FONT COLOR="""fc""">",teams.i,0)
teams.i=insert("<TR><TD BGCOLOR="""BG""" ALIGN=""CENTER"" VALIGN=""MIDDLE""><FONT COLOR="""fc""">"i")",teams.i,0)
teams.i=space(teams.i,1)
call writeln(stats,teams.i)
if reg ~= 0 then do
if i = (tcount-reg) & posreg~=0 then do /* was posreg */
call writeln(stats,"<TR bgcolor=""#FF0000""><TD colspan=""10"" bgcolor=""#FF0000"" height=1></TD></TR>")
end
end
if promo ~= 0 then do
if i = (promo) & pospro~=0 then do /* was pospro */
call writeln(stats,"<TR bgcolor=""#00cc00""><TD colspan=""10"" bgcolor=""#00cc00"" height=1></TD></TR>")
end
end
end
call writeln(stats,"</TABLE><BR>")
call writeln(stats,"<small>Created using HTML_Table.rexx script for Football 1999</small><BR>")
call writeln(stats,"</DIV></BODY>")
call writeln(stats,"</HTML>")
if flag ~= 1 then do
close(stats)
say
say center(htmt_t16,78)
say"-------------------------------------------------------------------------------------------"
say
say" "htmt_t17
htmt_ul = ""
do ji=1 to length(htmt_t17)
htmt_ul = htmt_ul"-"
end
say" "htmt_ul
say
say" HTML_Table "htmt_t18":"
say
say" " htmlpath||lname||"tab.html"
say
say" "htmt_t19
say" "htmt_t20
say" "htmt_t21
say" "htmt_t22
say
say" "htmt_t23":"
say
say" http://www.blue-shantung.demon.co.uk"
say
say
say"-------------------------------------------------------------------------------------------"
end
exit